
import controlP5.*;
ControlP5 controlP5;
controlP5.Textfield myTextfield;
controlP5.Button myButton;
controlP5.Bang myBang;
controlP5.Knob moveRate;
controlP5.Slider mySlider;

boolean enter = false;
int dx;
float[] offsets = new float[3];
float[] rotations = new float[3];


void keyPressed() {
  if (key == ENTER || key == RETURN) {
    if (enter == false){
	enter = true;
        int  xbuttonSpace   = (width/5);
        int  ybuttonSpace = (height/8);
          for (int guiEle_posx = 0; guiEle_posx < width ; guiEle_posx+=xbuttonSpace){
            for (int guiEle_posy = (height/2); guiEle_posy < height ; guiEle_posy+=ybuttonSpace){
              switch (guiEle_posy){
                case 0:
                  myTextfield = controlP5.addTextfield("Searching", xbuttonSpace, guiEle_posy,80,20); 
                  myButton = controlP5.addButton("buttonA", 0, xbuttonSpace, guiEle_posy,80,20);
                  this.myBang = controlP5.addBang("Enable_Path", xbuttonSpace,guiEle_posy, 20,20);
                  this.moveRate = controlP5.addKnob("knob1",0,360,0,xbuttonSpace,guiEle_posy,50);
                  this.mySlider = controlP5.addSlider("slider2",0,255,128,xbuttonSpace,guiEle_posy,100,10);
                  
              }
            }
          }
    } 
    else if (enter == true){
	enter = false;
	myTextfield.remove();
	myButton.remove();
        myBang.remove();
        moveRate.remove();
        mySlider.remove();
    }
  } 
}
private void searchbox()
{
  pushMatrix();
  stroke(128,60);
  fill(#ffffff,120);
  translate(0,height/2);
  rect(0,0,width,height/2); 
  //this.myTextfield.setFocus(true);
  popMatrix();
}

public void Searching(String theText) {
  // receiving text from Search textbox
  println(theText);
}
public void buttonA(int theValue) {
  println("a button event from buttonA: "+theValue);
}

public void Enable_Path(){
  println("Path");
  // call node.drawpath;
  // TODO
}

public void oneScreenText(){
  hint(ENABLE_DEPTH_TEST);
  pushMatrix();
    stroke(128,60);
    fill(30);
    rect(0,0,100,100);
    textSize(10);
    fill(255);
    text("Sniffers Online",10, 25,0);
    text("Phone Sniffed",10, 50,0);
  popMatrix();
  hint(DISABLE_DEPTH_TEST); 
}



